import Vue from "vue";
import Vuex from "vuex";
import {getHotSound} from "../api/index";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    info:{},
    banner:[],
    channel:[],
    sound:[]
  },
  mutations: {
    headList(state,{banner,channel,sound}){
      state.info = info;
      state.banner = banner;
      state.channel = channel;
      state.sound = sound;
    }
  },
  actions: {
    getSoundList:function(context){
      if(context.state.info.length === 0){
        getHotSound().then(result =>{
          const {info} = result;
          const {banner,channel,sound} = info;
          return result;
          context.commit('headList',{banner,channel,sound});
        })
      }
    }
  },
});
